package Part2_自定义泛型;

import java.util.ArrayList;

/**
 * ClassName: Order
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.04.18 15:40
 */
public class Order<T> {

    T t; //不确定的类型
    int orderID;

    public Order() {
    }

    public Order(T t, int orderID) {
        this.t = t;
        this.orderID = orderID;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    public int getOrderID() {
        return orderID;
    }

    public void setOrderID(int orderID) {
        this.orderID = orderID;
    }

    @Override
    public String toString() {
        return "t=" + t + ", orderID=" + orderID;
    }


    //自定义泛型方法
    //可根据需要声明为static
    public <E> ArrayList<E> copy(E[] arr){
        ArrayList<E> list = new ArrayList<>();
        for(E e: arr){
            list.add(e);
        }
        return list;
    }
}
